#include<bits/stdc++.h>
#define eps 1e-9
using namespace std;
template<typename Tp> inline void read(Tp &x){
    x=0;bool f=0;
    char c=getchar();
    while(!isdigit(c)&&c!='-')c=getchar();
    if(c=='-')f=1,c=getchar();
    while(isdigit(c))x=x*10+c-'0',c=getchar();
    if(f)x=-x;
}
template<typename Tp> inline void write(Tp x){
    if(x<0)putchar('-'),x=-x;
    if(x/10)write(x/10);
    putchar(x%10+'0');
}
const int N=100005;
struct car{
    int d,v,a,r1,r2;
    double e;
}c[N];
int T,n,m,L,V;
double p[N];
bool cmp(car ca,car cb){
    return ca.d<cb.d;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    read(T);
    while(T--){
        int ans=0;
        read(n),read(m),read(L),read(V);
        for(int i=1;i<=n;i++){
            read(c[i].d),read(c[i].v),read(c[i].a);
            if(c[i].a<0)c[i].e=min(1.0*L,-1.0*c[i].v*c[i].v/(c[i].a*2));
            else c[i].e=n;
            c[i].r1=c[i].r2=0;
        }
        sort(c+1,c+1+n,cmp);
        for(int i=1;i<=m;i++)read(p[i]);
        for(int i=1;i<=n;i++){
            if(c[i].a==0){
                if(c[i].v>V){
                    int t=lower_bound(p+1,p+1+m,c[i].d)-p;
                    if(t>m)continue;
                    c[i].r1=t;
                    c[i].r2=m;
                    ans++;
                }
            }
            else if(c[i].a>0){
                double exr=1.0*c[i].d+1.0*(1ll*V*V-1ll*c[i].v*c[i].v)/(c[i].a*2);
                if(exr<=L){
                    int t=upper_bound(p+1,p+1+m,exr)-p;
                    if(t>m)continue;
                    c[i].r1=t;
                    c[i].r2=m;
                    ans++;                    
                }
            }
            else{
                if(c[i].v>V){
                    double exr=1.0*c[i].d+1.0*(1ll*V*V-1ll*c[i].v*c[i].v)/(c[i].a*2);
                    int t=upper_bound(p+1,p+1+m,exr)-p;
                    int tb=lower_bound(p+1,p+1+m,c[i].d)-p;
                    if(t>m||tb>=t)continue;
                    c[i].r1=tb;
                    c[i].r2=t;
                    ans++;                    
                }
            }
        }
        write(ans);
        putchar(' ');
        write(m-1);
        putchar('\n');
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}